<template>
  <el-form>
    <el-form-item label="SKU标题" prop="title" :label-width="formLabelWidth">
      <el-col :span="12">
        <el-input v-model="form.title" size="small"></el-input>
      </el-col>
    </el-form-item>

    <el-form-item label="规格图片上传" :label-width="formLabelWidth">
      <el-col :span="20" class="tl">
        <el-radio-group v-model="form.is_pic">
          <el-radio label="1">开</el-radio>
          <el-radio label="0">关</el-radio>
        </el-radio-group>
      </el-col>
    </el-form-item>

    <el-form-item label="SKU描述" :label-width="formLabelWidth">
      <el-col :span="20">
        <el-input v-model="form.description" size="small"></el-input>
      </el-col>
    </el-form-item>

    <div class="tc">
      <el-button
        :loading="$store.state.isLoading"
        type="primary"
        @click="addMenu"
        >立即提交</el-button
      >
    </div>
  </el-form>
</template>
<script>
export default {
  data() {
    return {
      op: [],
      option: this.$store.state.sku || [],
      optionProps: {
        value: "id",
        label: "title",
        children: "z",
      },
      form: this.sku_form || {},
      formLabelWidth: "120px",
      placeText: "请选择栏目添加",
    };
  },
  props: {
    sku_form: {
      type: Object,
      default: () => {},
    },
  },
  mounted: {},
  methods: {
    addMenu() {
      var params = {};
      params = this.form;
      if (params.id) {
        this.$api.getShops.updateSku(params).then((res) => {
          if (res.data.code == 200 && res.data.status == 1 && res.data.result) {
            this.$store.dispatch("getSkuListTree", new Date());
            this.$emit("updateSku");
          } else {
            this.$fnc.alertError(res.data.code_desc, res.data.result); //失败弹出框
          }
        });
      } else {
        this.$api.getShops.addSku(params).then((res) => {
          if (res.data.code == 200 && res.data.status == 1 && res.data.result) {
            this.$emit("updateSku");
          } else {
            this.$fnc.alertError(res.data.code_desc, res.data.result); //失败弹出框
          }
        });
      }
    },
  },
};
</script>

